function [handvec,irf_zmat,irf_smat,ssvec]=irf_quick(funcmod,parmode,solveopt,addsol,nper,repnames,flag_plot,flag_unit)
% Quickly compute the IRFS to check being reported correctly 

% Solution of the model given by 
% *Transition Equation* $$ Y_{t} = GG Y_{t-1} + RR \eta_{t} $$ and variance covariance matrix, 
% where $$ S_{t} $$ is the vector of all
% variables (endogenous and exogenous) of the model of dimension [NY 1],
% and $$ \eta $$  is the vector of exogenous innovations of dimension [NX 1] with 
% variance covariance matrix $$ V(\eta) = SDX'SDX $$. 

[GG, RR, CONS, eu, SDX, ZZ, initss, ssvec, flag, ssnames, stanames ,shonames]...
    =feval(funcmod,parmode,solveopt,addsol);
if isstruct(shonames)==true; 
    shonames=shonames.long; 
end 
if ~isequal( eu,[1;1] )
    disp('Cannot solve model')
    handvec=[]; irf_zmat=[]; irf_smat=[]; ssvec=[];
    return; 
end
if nargin < 8 
    flag_unit=0; 
end

[state_pos,flag_adds]=extractlevels(repnames,stanames);
ns=length(state_pos);
nx=size(SDX,1);
nz=size(ZZ, 1);
irf_smat=zeros(ns,nper,nx);
irf_zmat=zeros(nz,nper,nx);
level_indic=find(flag_adds==1);
for ii=1:nx
    if flag_unit==0
        resp=SDX(ii,ii)*RR(:,ii);
    else
        resp=RR(:,ii);
        disp('Unit Impulse'); 
    end                
    irf_smat(:,1,ii)=resp(state_pos);
    irf_zmat(:,1,ii)=ZZ*resp;
    for jj=2:nper
        resp=GG*resp;
        irf_smat(:,jj,ii)=resp(state_pos);
        irf_zmat(:,jj,ii)=ZZ*resp;
    end
    if ~isempty(level_indic);
        check = squeeze(irf_smat(level_indic,:,ii));
        check =cumsum(check,2);
        irf_smat(level_indic,:,ii)=check   ;%reshape(check,[length(level_indic) nper 1] );
    end
end
if flag_plot~=1;
    handvec=[];
    return;
end
if ns <= 14
    ncol=2;
    titfont=11;
elseif ns > 14 && ns <=21
    ncol=3;
    titfont=10;
else
    titfont=8;
    ncol=4;
end
nrow=ceil(ns/ncol);
xx=(0:nper-1)';
handvec=zeros(nx,1);
for ii=1:nx
    handvec(ii)=figure;
    for jj=1:ns
        subplot(nrow,ncol,jj);
        yy=squeeze( irf_smat(jj,:,ii) );
        plot(xx,yy,'k','LineWidth',2  );
        axis tight;
        title(repnames{jj},'Fontsize',titfont);
    end
    tithand=suptitle(shonames{ii},16 );
    set(tithand,'FontWeight','bold');
    set(handvec(ii),'PaperPosition',[0.75 0.5 7.5 10]);
end
end
